<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";

	String org_id = request.getParameter("org_id");
	String EQUIPMENT_JHSJSJ = request.getParameter("EQUIPMENT_JHSJSJ");
	String EQUIPMENT_JHSJSJ2 = request.getParameter("EQUIPMENT_JHSJSJ2");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 								
	<head> 							
		<%@ include file="../jslib/jquerylib.jsp" %>
	    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
        <link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="<%=request.getContextPath() %>/jslib/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css"/>
        <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/ztree/jquery.ztree.core-3.4.js"></script>
        <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
	       <!-- 删除结果信息返回 -->
	    	<c:if test="${requestScope.message!=null}">
				<script type="text/javascript">
	  	 		     alert('<c:out value="${requestScope.message}"></c:out>');
	  	 		     window.close();
	  			</script>
	        </c:if>
	 
	<script type="text/javascript">
	$(document).ready(function(){
				//高级搜索需要的js
				buttonStatus=1;
				$("#flip").click(function(){
					if(buttonStatus==1){
						$("#panel").slideToggle("slow");
						$("#flip").toggleClass("btnStatus2");
						buttonStatus=1;
					}else{
						$("#panel").slideUp("slow");
						$("#flip").toggleClass("btnStatus2");
					}
			 });
				 //高级搜索结束
					$("#gridTable").jqGrid({
						url:'<%=request.getContextPath() %>/eqAction!queryZhoujList.action?org_id=<%=org_id%>&shij1=<%=EQUIPMENT_JHSJSJ%>&shij2=<%=EQUIPMENT_JHSJSJ2%>',
						datatype: "json",
						height: 350,
						width: 410, 
						autowidth: true, 
						colNames:['序号','部门','设备编号','设备名称','规格型号','出厂编号','检定/校准参数','计量状态','确认间隔','计划送检时间','检定校准有效期','检定单位','计量类别'],
						colModel:[
								{name:'ID',index:'ID', width:60, key:true, sorttype:"int",hidden:true,hidedlg:true}, 
								{name:'EQUIPMENT_ORG_NAME',index:'EQUIPMENT_ORG_NAME', width:100},								
								{name:'EQUIPMENT_NO',index:'EQUIPMENT_NO', width:100},
								{name:'EQUIPMENT_NAME',index:'EQUIPMENT_NAME', width:110},
								{name:'EQUIPMENT_GGXH',index:'EQUIPMENT_GGXH', width:110},
								{name:'EQUIPMENT_CCBH',index:'EQUIPMENT_CCBH', width:110},
								{name:'EQUIPMENT_JDJZCS',index:'EQUIPMENT_JDJZCS', width:110},
								{name:'EQUIPMENT_JDZT',index:'EQUIPMENT_JDZT', width:110,hidden:true},
								{name:'EQUIPMENT_QRJG',index:'EQUIPMENT_QRJG', width:110},
								{name:'EQUIPMENT_JHSJSJ',index:'GONGYINGSHANGPINGJIAURL', width:110,hidden:true},
								{name:'EQUIPMENT_JDJZYXQ',index:'EQUIPMENT_JDJZYXQ', width:110},
								{name:'EQUIPMENT_JDDW',index:'EQUIPMENT_JDDW', width:110},
								{name:'EQUIPMENT_JLLB',index:'EQUIPMENT_JLLB', width:110}
					],
					shrinkToFit:false,
					sortname:'id',
					sortorder:'desc',
					viewrecords:true,
					multiselect: true, // 是否显示复选框
					multiboxonly : true, 
					//gridview: true,  //提升速度
					rownumbers: true,//显示行号
					rownumWidth: 30, //行号的宽度
					rowNum:15,
					rowList:[15,20,50,200,500],
					toolbar: [false,"top"],
					loadComplete: function() {
						var ids = jQuery("#gridTable").getDataIDs();
				        if(ids.length<20){
				        	 jQuery("#gridTable").jqGrid('setGridHeight',390); 
				        	 parent.document.getElementById("mainframe").height=670; 
				        }else{
				        	 jQuery("#gridTable").jqGrid('setGridHeight',ids.length*24); 
				        	 parent.document.getElementById("mainframe").height=ids.length*24+410; 
				        }
				        var n = jQuery("#gridTable").getGridParam('records'); 
					},
					jsonReader: {
						root:"rows",		// 数据行（默认为：rows）
						page: "page",  	// 当前页
						total: "total",  // 总页数
						records: "records",  // 总记录数
						repeatitems : false		// 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
					},
					prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
					pager:"#gridPager",
					caption: "周期检定计划列表"
			});
			    $("#consoleDlg").dialog({
			        autoOpen: false,      
			        modal: true,    // 设置对话框为模态（modal）对话框  
			        resizable: true,      
			        width: 700,  
			        buttons: {  // 为对话框添加按钮  
			            "关闭": function() {$("#consoleDlg").dialog("close")}
			        }  
			    }); 
				 jQuery("#gridTable").jqGrid('navGrid','#gridPager',{add:false,edit:false,del:false,search:false,refresh:false});
					jQuery("#gridTable").jqGrid('navButtonAdd','#gridPager',
								{ 	
								caption: "",                          
								onClickButton : function (){                               
								jQuery("#gridTable").jqGrid('setColumns');                           
								}
					}); 
								doResize(); 
	}); 
	
	//执行大小
	function doResize() { 
		var ss = getPageSize(); 
			 $("#gridTable").jqGrid('setGridHeight', ss.WinH-345);
			 $("#gridTable").jqGrid('setGridWidth', ss.WinW-30); 
			} 

		//导出
		function expExcel(){
			var colNames = jQuery("#gridTable").jqGrid('getGridParam','colNames');
			var titleNames ="";
			var fieldsNames ="";
			for(var i=2;i<colNames.length;i++){
			titleNames+=colNames[i]+",";
			} 
			titleNames = encodeURIComponent(titleNames);
			var colModel = jQuery("#gridTable").jqGrid('getGridParam','colModel');
			for(var i=2;i<colModel.length;i++){
			fieldsNames+=colModel[i]["name"]+",";
			} 
			fieldsNames = encodeURIComponent(fieldsNames);
			$('#form1').attr("action","<%=request.getContextPath() %>/eqAction!exportExcelZQJDJH.action?org_id=<%=org_id%>&shij1=<%=EQUIPMENT_JHSJSJ%>&shij2=<%=EQUIPMENT_JHSJSJ2%>&titleNames="+titleNames+"&fieldsNames="+fieldsNames);
			$('#form1').submit();
		}
	</script>	
	</head>
	<body>
	<form action="" method="post" id="form1">
			<table style="width: 100%;" class="tableCont">
				<tr>
					<td height="25" valign="top">
					<input id="excelExp" type='button' value='导 出' onclick='expExcel()' class='button_b' />
				</tr>
				<tr>
					<td colspan="4" style="padding-top:8px;">
						<table id="gridTable"></table>
						<div id="gridPager"></div>
					</td>
				</tr>
		   </table>
	</form>
	</body>
</html>
